FROM ubuntu:xenial

MAINTAINER atompi <atompi@foxmail.com>

# init
WORKDIR /usr/local/src
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN dpkg-reconfigure -f noninteractive tzdata
COPY sources.list /etc/apt/sources.list
RUN echo "nameserver 114.114.114.114" >> /etc/resolv.conf
RUN apt-get update

# install nginx apache2-utils
RUN apt install nginx apache2-utils -y

# install kibana
COPY kibana-4.6.4-linux-x86_64.tar.gz /usr/local/src
RUN tar -zxf kibana-4.6.4-linux-x86_64.tar.gz && mv kibana-4.6.4-linux-x86_64 /opt/kibana

# config kibana
ENV KIBANA_PWD=atompi
COPY kibana.conf /etc/nginx/conf.d/
RUN htpasswd -cb /opt/kibana/htpasswd.users kibana $KIBANA_PWD
RUN echo "server.host: \"localhost\"" >> /opt/kibana/conf/kibana.conf && \
      echo "elasticsearch.url: \"http:\/\/$ELS_HOST:9200\""

# start kibana and nginx
RUN nginx -t
RUN nginx -s reload
RUN mkdir /var/log/kibana
RUN nohup /opt/kibana/bin/kibana > /var/log/kibana/kibana.log &
EXPOSE 80
CMD ["tail","-f","/var/log/kibana/kibana.log"]
